#include "../include/list.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define OK		0
#define ERR 	-1
#define NONE	0
#define LEFT	1
#define RIGHT	2
#define TRUE 	1
#define FALSE 	0


typedef struct grammaticCDT *grammaticADT;

/*
	Build a grammatic
	return NULL if it fails.
*/
grammaticADT NewGrammatic(char * name);

/*
	Add the initial symbol
	return OK succesful, ERR otherwise.
*/
int AddInitialSymbol(grammaticADT g, char * symbol);

/*
	Add a symbol to a list of Not Terminal
	Symbols.
	return OK succesful, ERR otherwise
*/
int AddVN(grammaticADT g, char * symbol);

/*
	Add a symbol to a list of Terminal
	Symbols.
	return OK succesful, ERR otherwise
*/
int AddVT(grammaticADT g, char * symbol);

/*
	Add a production to a list of Productions
	return OK succesful, ERR otherwise
*/
int AddProduction(grammaticADT g, char * p);

/*
	Check if given symbol belongs to
	defined Not Terminal Symbols
	return TRUE true, FALSE false.
*/
int VNcontains(grammaticADT g, char * symbol);

/*
	Check if given symbol belongs to
	defined Terminal Symbols
	return TRUE true, FALSE false.
*/
int VTcontains(grammaticADT g, char * symbol);

/*
	Obtain for given grammatic is regular to left
	or to right
	return LEFT to left, RIGHT to right.
*/
int GrammaticDirection(grammaticADT g);

int GetDirection(grammaticADT g, char * p);

/*
	Get the name of this grammatic
*/
char * GetName(grammaticADT g);

/*
	Get the initial symbol of this grammatic
*/
char * GetInitialSymbol(grammaticADT g);

/*
	Validate a given grammatic
	return TRUE grammatic valid, or FALSE otherwise.
*/
int IsValidGrammatic(grammaticADT g, char * msg);

/*
	Check if a given production is regular
	return TRUE true or FALSE
*/
int IsRegularProduction(grammaticADT g, char * p);

/*
	Check if the grammatic is regular
	return TRUE true or FALSE
*/
int IsRegularGrammatic(grammaticADT g);

/*
	Free the resources
*/
void FreeGrammaticADT(grammaticADT g);

void ShowVTs(grammaticADT g, FILE * f);
void ShowVNs(grammaticADT g, FILE * f);
void ShowProductions(grammaticADT g, FILE * f);
void ShowInitialSymbol(grammaticADT g, FILE * f);
